package mvc;

import controller.*;
import views.*;
import multiformat.*;
import javax.swing.*;
import java.awt.*;

/**
 * De MVC Klasse
 * @author Minkey
 */
public class MVC extends JFrame{
	Calculator calc;
	BaseController base;
	FormatController format;
	InputController input;
	CalculationHistory history;
	
	/**
	 * Hier wordt de GUI gemaakt. 
	 * @param args
	 */
	public static void main(String [] args){
		Calculator calc;
		BaseController base;
		FormatController format;
		InputController input;
		CalculationHistory history;
		
		history = new CalculationHistory();
		
		JFrame frame= new JFrame();
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
		frame.setSize(300,300);
		
		calc = new Calculator();
		history = new CalculationHistory();
		
		frame.setLayout(new GridLayout(2,1));
		
		JPanel panel = new JPanel();
		panel.setLayout(new BorderLayout());
				
		base = new BaseController(calc);
		panel.add(base, BorderLayout.NORTH);
		
		format = new FormatController(calc);
		panel.add(format, BorderLayout.CENTER);
		
		input = new InputController(calc, history);
		panel.add(input, BorderLayout.SOUTH);
		
		frame.add(panel);
		
		frame.add(history);
		
		calc.addActionListener(base);
		calc.addActionListener(format);
		calc.addActionListener(input);
		
		frame.setVisible(true);
	}
}
